<?php

  $WorkTable = &$_SQL_TABLE[$GlobPart];

  $TabFields['aug'] = getFieldNamesWithLangs($_SQL_TABLE['admin_user_group'], array('title'));
  $MenuGroupsSelect = array_kv(getTableAsArray($_SQL_TABLE['admin_menu_group'], $TabFields['amg']['title'], array(), '', 'code,'.$TabFields['amg']['title']), $TabFields['amg']['title'], 'code');
  $AdminUserGroupsSelect = array_kv(getTableAsArray($_SQL_TABLE['admin_user_group'], $TabFields['aug']['title'], array(), '', 'code,'.$TabFields['aug']['title']), $TabFields['aug']['title'], 'code');

  if($_REQUEST['mode'] == $GlobPart)
  {
    //$PageTitle = '$language["admin"]["menu"]." :: ".$language["admin"][$Item["langvarname"]]." (".$Item["title_en"].")";';
    $PageTitle = '$language["admin"]["adminMenu"]." :: ".$Item["'.$TabFields['am']['title'].'"];';
  }
  else
  {
  	$PageTitle = '$language["admin"]["adminMenu"];';
  	$AloneMode = $GlobPart;

  	$Query['FromTables'] = 	$WorkTable." am
  							LEFT JOIN ".$_SQL_TABLE['admin_menu_group']." amg ON amg.code = am.menu_group
  							";
  	$Query['Fields'] = "am.*, amg.".$TabFields['amg']['title']." AS menu_group";
  	$Query['TabOrder'] = "am.";
  	$Query['Where'] = "";
  	$Query['GroupBy'] = "";

  	$EnableFilter = true;

  	$listInfo['where']['menu_group'] = array(
  								'simple' => 'y',
  								'SQLField' => "am.menu_group = '".$CONFIG['AdminFilterValuePat']."'",
  								'type' => 'select',
  								'title' => $language['admin']['menuGroup'],
  								'values' => array('' => $language['admin']['all']) + $MenuGroupsSelect,
  								'JSact' => '',
  								);

    require_once __CFG_PATH_CODE_ADMIN."admin.filter.inc";

  }

  $ConfLangArr = array(
				'title_' => array(
								'type' => 'input',
								'title' => $language['admin']['name'],
								'useInAddForm' => 'y',
								'addVariable' => $_POST,
								'useInList' => $CONFIG['useInListSort'],
								'inListEdit' => 'list_input',
								'useInListEdit' => 'y',
								'required' => $CONFIG['AdminReqPatAll'],
								'maxlength' => '80',
								));

  $GeneratedLangArr = getAdminConfigArrayWithLangs($ConfLangArr, $LANGS);


  $_SQL_TABLE_FIELDS[$GlobPart] = $GeneratedLangArr + array(

				'linkvar' => array(
								'type' => 'input',
								'title' => $language['admin']['linkVar'],
								'useInAddForm' => 'y',
								'addVariable' => $_POST['linkvar'],
								'useInList' => $CONFIG['useInListSort'],
								'required' => $CONFIG['AdminReqPatVariable'],
								'maxlength' => '50',
								),

				'addlinkvars' => array(
								'type' => 'input',
								'title' => $language['admin']['addLinkVars'],
								'useInAddForm' => 'y',
								'addVariable' => $_POST['addlinkvars'],
								'useInList' => $CONFIG['useInListSort'],
								'maxlength' => '255',
								),

				'menu_group' => array(
								'type' => 'select',
								'title' => $language['admin']['menuGroup'],
								'useInAddForm' => 'y',
								'addVariable' => $_POST['menu_group'],
								'useInList' => $CONFIG['useInListSort'],
								'values' => $MenuGroupsSelect,
								'orderby' => $TabFields['amg']['title'].',am.'.$TabFields['am']['title'],
								'tabord' => 'amg.',
								'required' => $CONFIG['AdminReqPatAll'],
								),

				'sorting' => array(
								'type' => 'input',
								'title' => $language['admin']['sorting'],
								'useInAddForm' => 'y',
								'addVariable' => $_POST['sorting'],
								'useInList' => $CONFIG['useInListSort'],
								'size' => 3,
								'maxlength' => '3',
								'inListEdit' => 'list_input',
								'useInListEdit' => 'y',
								),

				'active' => array(
								'type' => 'select_link',
								'title' => $language['admin']['status'],
								'formid' => $CONFIG['activeFormName'],
								'addVariable' => $CONFIG['addAdminMenuActive'],
								'noUseInEdit' => 'y',
								'useInList' => $CONFIG['useInListSort'],
								'inListEdit' => 'select_link',
								'values' => array(
											'y' => array(
													'title' => $language['admin']['active'],
													'className' => 'active',
													'formFields' => array(
																	'act' => 'status',
																	'varvalue' => 'n',
																	'varname' => 'active',
																	getKeyVarName() => '{$Item.$WorkTableKeyFieldName}',
													),
											),
											'n' => array(
													'title' => $language['admin']['inactive'],
													'className' => 'inactive',
													'formFields' => array(
																	'act' => 'status',
																	'varvalue' => 'y',
																	'varname' => 'active',
																	getKeyVarName() => '{$Item.$WorkTableKeyFieldName}',
													),
											),
								),
				),


				'date' => array(
								'type' => 'value',
								'title' => $language['admin']['date'],
								'addVariable' => 'NOW()',
								'addVarType' => $CONFIG['VarTypeSQLFunction'],
								'useInList' => $CONFIG['useInListSort'],
								'useInListEdit' => 'y',
								),

				'user_group_menu' => array(
								'type' => 'checkboxes',
								'title' => $language['admin']['userGroups'],
								'listOfRelations' => 'y',
								'useInAddForm' => 'y',
								'addVariable' => $_POST['user_group_menu'],
								'separator' => '<br />',
								'values' => $AdminUserGroupsSelect,
								'selected' => array_kv(getTableAsArray($_SQL_TABLE['admin_menu_user_group'], '', array("admin_menu = '".$_REQUEST[getKeyVarName()]."'", "active = 'y'")), 'user_group'),
								'tableInfo' => array(
  											'name' => $_SQL_TABLE['admin_menu_user_group'],
  											'keyField' => 'admin_menu',
  											'relatedField' => 'user_group',
  											'keyFieldValue' => $_REQUEST[getKeyVarName()],
  								),
				),

  );

  $_SQL_TABLE_EDIT_FORMS[$GlobPart] = array('active');



?>